package com.easylinkin.linkappapi.danger.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Transient;

import java.util.Date;
import java.util.Objects;


@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("app_danger_type")
public class DangerType extends Model<DangerType> {
    /**
     * 主键
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    public DangerType() {
    }

    public DangerType(Long dangerTypeId, String fullId, String fullName, String name, String code, Integer level) {
        this.dangerTypeId = dangerTypeId;
        this.fullId = fullId;
        this.fullName = fullName;
        this.name = name;
        this.code = code;
        this.level = level;
    }

    /**
     * 父id
     */
    private Long parentId;

    /**
     * 隐患类型id
     */
    private Long dangerTypeId;

    /**
     * 原全称id
     */

    private String fullId;

    /**
     * 全名
     */

    private String fullName;

    /**
     * 最后同步时间
     */
    private Date lastPushTime;

    /**
     * 名称
     */
    private String name;

    /**
     * 编码
     */
    private String code;

    /**
     * 层级
     */
    private Integer level;

    private String tenantId;

    /**
     * 节点类型，1隐患分类，2隐患内容
     */
    @TableField(exist = false)
    private Integer nodeType;

    /**
     * 其下存在 隐患内容
     */
    @TableField(exist = false)
    private Boolean hasDangerContent;

    /**
     * 隐患
     */
    @TableField(exist = false)
    private Danger danger;


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        DangerType that = (DangerType) o;
        return dangerTypeId.equals(that.dangerTypeId) && fullId.equals(that.fullId) && fullName.equals(that.fullName) && name.equals(that.name) && code.equals(that.code) && level.equals(that.level);
    }

    @Override
    public int hashCode() {
        return Objects.hash(dangerTypeId, fullId, fullName, name, code, level);
    }


    public DangerType(Long dangerTypeId, String fullId, String fullName, String name, String code, Integer level,Integer nodeType) {
        this.dangerTypeId = dangerTypeId;
        this.fullId = fullId;
        this.fullName = fullName;
        this.name = name;
        this.code = code;
        this.level = level;
        this.nodeType = nodeType;
    }
}
